package br.com.managerprojectplugin.view;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import br.com.managerprojectplugin.model.Usecase;

public class TesteTree {
	public static void main(String[] args) {
		Display display = Display.getDefault();
		Shell shell = new Shell(display);
		shell.setText("Testando como UseCase esta se comportando");
		shell.setLayout(new GridLayout());
		GridData gd = new GridData();
		gd.horizontalAlignment = SWT.FILL;
		gd.verticalAlignment = SWT.FILL;
		gd.grabExcessVerticalSpace = true;
		gd.grabExcessHorizontalSpace = true;

		Usecase[] uc = new Usecase[5];
		for (int i = 0; i < uc.length; i++) {
			uc[i] = new Usecase();
			uc[i].setCaseParent("CaseParent");
			uc[i].setEstado("solteiro");
			uc[i].setInicio("hoje");
			uc[i].setNome("elton");
			uc[i].setNomeProjeto("chartner");
			uc[i].setProjetoDesc("novo");
			uc[i].setTerminno("ontem");
		}
		
		TreeViewer treeViewer = new TreeViewer(shell, SWT.SINGLE);
		treeViewer.setContentProvider(new UseCaseContentProvider());
		treeViewer.setLabelProvider(new UseCaseLabelProvider());
		treeViewer.setInput(uc);
		treeViewer.setAutoExpandLevel(2);
		treeViewer.getTree().setLinesVisible(true);
		
		shell.open();

		while(!shell.isDisposed()) {
			if(!display.readAndDispatch()) {
				display.sleep();
			}
		}
		
	}
}
